﻿/*CLR Version: 4.0.30319.18063
 * Creat Date: 2017-10-12 10:49:19
 * Creat Year: 2017
 * Creator: 程炜.Snail
 */
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using Utility.Data.DbClient;
using Utility.Extensions;

namespace Utility.DBUtility.DatabaseOperate
{
    /// <summary>
    /// DB操作基础类接口定义
    /// </summary>
    public interface IDbHelper
    {
        /// <summary>
        /// 数据库类型
        /// </summary>
        DBParameterExtensions.DatabaseType DataBaseType
        {
            get;
        }
        #region Exists
        /// <summary>
        /// 判断表是否存在
        /// </summary>
        /// <param name="tableName">需要判断的表名</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns></returns>
        bool ExistsTable(string tableName, string connectionString = "");
        /// <summary>
        /// 是否存在
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns></returns>
        bool Exists(string strSql,string connectionString="");
        /// <summary>
        /// 是否存在
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        bool Exists(string strSql, params DBParameter[] cmdParms);
        /// <summary>
        /// 是否存在
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        bool Exists(string strSql, params IDataParameter[] cmdParms);
        /// <summary>
        /// 是否存在
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="cmdParms"></param>
        /// <param name="userMasterConnection">使用主数据库进行查询</param>
        /// <returns></returns>
        bool Exists(string strSql,bool userMasterConnection = false, params DBParameter[] cmdParms);
        /// <summary>
        /// 是否存在
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="cmdParms"></param>
        /// <param name="userMasterConnection">使用主数据库进行查询</param>
        /// <returns></returns>
        bool Exists(string strSql, bool userMasterConnection = false, params IDataParameter[] cmdParms);
        /// <summary>
        /// 是否存在
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        bool Exists(string strSql, string connectionString = "", params DBParameter[] cmdParms);
        /// <summary>
        /// 是否存在
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        bool Exists(string strSql, string connectionString = "", params IDataParameter[] cmdParms);
        /// <summary>
        /// 删除指定表数据
        /// </summary>
        /// <param name="values"></param>
        /// <param name="tableName"></param>
        /// <param name="connectionString"></param>
        /// <returns></returns>
        int Delete(Dictionary<string, object> values, string tableName, string connectionString = "");
        /// <summary>
        /// 删除指定表数据
        /// </summary>
        /// <param name="list"></param>
        /// <param name="tableName"></param>
        /// <param name="connectionString"></param>
        /// <returns></returns>
        int Delete(List<Utility.DBUtility.CustomParameter> list, string tableName, string connectionString = "");
        /// <summary>
        /// 判断指定表指定栏位值是否存在
        /// </summary>
        /// <param name="values">栏位名称/值</param>
        /// <param name="tableName">表名</param>
        /// <param name="userMasterConnection">是否使用主数据库进行查询</param>
        /// <returns></returns>
        bool Exists(Dictionary<string, object> values, string tableName, bool userMasterConnection);
        /// <summary>
        /// 判断指定表指定栏位值是否存在
        /// </summary>
        /// <param name="values">栏位名称/值</param>
        /// <param name="tableName">表名</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns></returns>
        bool Exists(Dictionary<string, object> values, string tableName, string connectionString = "");
        /// <summary>
        /// 判断指定表指定栏位值是否存在
        /// </summary>
        /// <param name="list">栏位名称/值</param>
        /// <param name="tableName"></param>
        /// <param name="userMasterConnection">是否使用主数据库进行查询</param>
        /// <returns></returns>
        bool Exists(List<Utility.DBUtility.CustomParameter> list, string tableName, bool userMasterConnection);
        /// <summary>
        /// 判断指定表指定栏位值是否存在
        /// </summary>
        /// <param name="list">栏位名称/值</param>
        /// <param name="tableName"></param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns></returns>
        bool Exists(List<Utility.DBUtility.CustomParameter> list, string tableName, string connectionString = "");

        /// <summary>
        /// 判断指定表指定栏位值是否存在
        /// </summary>
        /// <param name="column">列名</param>
        /// <param name="value">值</param>
        /// <param name="tableName">表名</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns></returns>
        bool Exists(string column, dynamic value, string tableName,string connectionString="");
        #endregion

        #region ExecuteSql/ExecuteScalar/ExecuteReader
        /// <summary>
        /// 执行SQL语句，返回影响的记录数
        /// </summary>
        /// <param name="strSql">SQL语句</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns>影响的记录数</returns>
        int ExecuteSql(string strSql, string connectionString = "");
        /// <summary>
        /// 执行多条SQL语句，实现数据库事务。
        /// </summary>
        /// <param name="strSqlList">多条SQL语句</param>  
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>  
        int ExecuteSqlTran(List<string> strSqlList,string connectionString="");
        /// <summary>
        /// 执行一条计算查询结果语句，返回查询结果
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="strSql">计算查询结果语句</param>
        /// <param name="userMasterConnection">是否使用主数据库进行查询</param>
        /// <returns>查询结果</returns>
        T ExecuteScalar<T>(string strSql, bool userMasterConnection);
        /// <summary>
        /// 执行一条计算查询结果语句，返回查询结果
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="strSql">计算查询结果语句</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns>查询结果</returns>
        T ExecuteScalar<T>(string strSql, string connectionString = "");
        /// <summary>
        /// 执行一条计算查询结果语句，返回查询结果
        /// </summary>
        /// <param name="strSql">计算查询结果语句</param>
        /// <param name="userMasterConnection">是否使用主数据库进行查询</param>
        /// <returns>查询结果</returns>
        object ExecuteScalar(string strSql, bool userMasterConnection);
        /// <summary>
        /// 执行一条计算查询结果语句，返回查询结果（object）。
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns></returns>
        object ExecuteScalar(string strSql, string connectionString = "");
        /// <summary>
        /// 执行查询语句，返回OracleDataReader ( 注意：调用该方法后，一定要对IDataReader进行Close )
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="userMasterConnection">是否使用主数据库进行查询</param>
        /// <returns></returns>
        IDataReader ExecuteReader(string strSql, bool userMasterConnection);
        /// <summary>
        /// 执行查询语句，返回OracleDataReader ( 注意：调用该方法后，一定要对IDataReader进行Close )
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns></returns>
        IDataReader ExecuteReader(string strSql, string connectionString = "");
        /// <summary>
        /// 获取指定表指定栏位的记录数
        /// </summary>
        /// <param name="column"></param>
        /// <param name="value"></param>
        /// <param name="tableName"></param>
        /// <returns></returns>
        int GetCountByColumn(string column, dynamic value, string tableName);
        /// <summary>
        /// 获取指定表指定栏位的记录数
        /// </summary>
        /// <param name="column"></param>
        /// <param name="value"></param>
        /// <param name="tableName"></param>
        /// <param name="connectionString"></param>
        /// <returns></returns>
        int GetCountByColumn(string column, dynamic value, string tableName, string connectionString = "");

        #region 执行带参数的SQL语句
        /// <summary>
        /// 执行SQL语句，返回影响的记录数
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        int ExecuteSql(string strSql, params DBParameter[] cmdParms);
        /// <summary>
        /// 执行SQL语句，返回影响的记录数
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        int ExecuteSql(string strSql, params IDataParameter[] cmdParms);
        /// <summary>
        /// 执行SQL语句，返回影响的记录数
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="userMasterConnection">是否使用主数据库进行查询</param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        int ExecuteSql(string strSql, bool userMasterConnection, params DBParameter[] cmdParms);
        /// <summary>
        /// 执行SQL语句，返回影响的记录数
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        int ExecuteSql(string strSql, string connectionString = "", params DBParameter[] cmdParms);
        /// <summary>
        /// 执行SQL语句，返回影响的记录数
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="userMasterConnection">是否使用主数据库进行查询</param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        int ExecuteSql(string strSql, bool userMasterConnection, params IDataParameter[] cmdParms);
        /// <summary>
        /// 执行SQL语句，返回影响的记录数
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        int ExecuteSql(string strSql, string connectionString = "", params IDataParameter[] cmdParms);
        /// <summary>
        /// 执行多条SQL语句，实现数据库事务。
        /// </summary>
        /// <param name="strSqlList">SQL语句的哈希表（key为sql语句，value是该语句的IDataParameter[]）</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns></returns>
        int ExecuteSqlTran(List<ExcuteSqlParameters> strSqlList, string connectionString = "");
        /// <summary>
        /// 执行一条计算查询结果语句，返回查询结果
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="strSql">计算查询结果语句</param>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <param name="cmdParms"></param>
        /// <returns>查询结果</returns>
        T ExecuteScalar<T>(string strSql, bool userMasterConnection, params DBParameter[] cmdParms);
        /// <summary>
        /// 执行一条计算查询结果语句，返回查询结果
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="strSql">计算查询结果语句</param>
        /// <param name="cmdParms"></param>
        /// <returns>查询结果</returns>
        T ExecuteScalar<T>(string strSql, params DBParameter[] cmdParms);
        /// <summary>
        /// 执行一条计算查询结果语句，返回查询结果
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="strSql">计算查询结果语句</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="cmdParms"></param>
        /// <returns>查询结果</returns>
        T ExecuteScalar<T>(string strSql, string connectionString = "", params DBParameter[] cmdParms);
        /// <summary>
        /// 执行一条计算查询结果语句，返回查询结果
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="strSql">计算查询结果语句</param>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <param name="cmdParms"></param>
        /// <returns>查询结果</returns>
        T ExecuteScalar<T>(string strSql, bool userMasterConnection, params IDataParameter[] cmdParms);
        /// <summary>
        /// 执行一条计算查询结果语句，返回查询结果
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="strSql">计算查询结果语句</param>
        /// <param name="cmdParms"></param>
        /// <returns>查询结果</returns>
        T ExecuteScalar<T>(string strSql, params IDataParameter[] cmdParms);
        /// <summary>
        /// 执行一条计算查询结果语句，返回查询结果
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="strSql">计算查询结果语句</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="cmdParms"></param>
        /// <returns>查询结果</returns>
        T ExecuteScalar<T>(string strSql, string connectionString = "", params IDataParameter[] cmdParms);
        /// <summary>
        /// 执行一条计算查询结果语句，返回查询结果
        /// </summary>
        /// <param name="strSql">计算查询结果语句</param>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <param name="cmdParms"></param>
        /// <returns>查询结果</returns>
        object ExecuteScalar(string strSql, bool userMasterConnection, params IDataParameter[] cmdParms);
        /// <summary>
        /// 执行一条计算查询结果语句，返回查询结果
        /// </summary>
        /// <param name="strSql">计算查询结果语句</param>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <param name="cmdParms"></param>
        /// <returns>查询结果</returns>
        object ExecuteScalar(string strSql, bool userMasterConnection, params DBParameter[] cmdParms);
        /// <summary>
        /// 执行一条计算查询结果语句，返回查询结果（object）。
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        object ExecuteScalar(string strSql, params DBParameter[] cmdParms);
        /// <summary>
        /// 执行一条计算查询结果语句，返回查询结果（object）。
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        object ExecuteScalar(string strSql, params IDataParameter[] cmdParms);
        /// <summary>
        /// 执行一条计算查询结果语句，返回查询结果（object）。
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        object ExecuteScalar(string strSql, string connectionString = "", params DBParameter[] cmdParms);
        /// <summary>
        /// 执行一条计算查询结果语句，返回查询结果（object）。
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        object ExecuteScalar(string strSql, string connectionString = "", params IDataParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句，返回OracleDataReader ( 注意：调用该方法后，一定要对IDataReader进行Close )
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="userMasterConnection">使用主库查询</param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        IDataReader ExecuteReader(string strSql,bool userMasterConnection, params DBParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句，返回OracleDataReader ( 注意：调用该方法后，一定要对IDataReader进行Close )
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="userMasterConnection">使用主库查询</param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        IDataReader ExecuteReader(string strSql, bool userMasterConnection, params IDataParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句，返回OracleDataReader ( 注意：调用该方法后，一定要对IDataReader进行Close )
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        IDataReader ExecuteReader(string strSql, params DBParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句，返回OracleDataReader ( 注意：调用该方法后，一定要对IDataReader进行Close )
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        IDataReader ExecuteReader(string strSql, string connectionString = "", params DBParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句，返回OracleDataReader ( 注意：调用该方法后，一定要对IDataReader进行Close )
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        IDataReader ExecuteReader(string strSql, params IDataParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句，返回OracleDataReader ( 注意：调用该方法后，一定要对IDataReader进行Close )
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        IDataReader ExecuteReader(string strSql, string connectionString = "", params IDataParameter[] cmdParms);
        #endregion

        #endregion

        #region Query
        /// <summary>
        /// 执行查询语句，返回DataTable
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <returns></returns>
        DataTable Query(string strSql, bool userMasterConnection);
        /// <summary>
        /// 执行查询语句，返回DataTable
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns></returns>
        DataTable Query(string strSql, string connectionString = "");
        /// <summary>
        /// 执行查询语句，返回DataSet
        /// </summary>
        /// <typeparam name="TKey">TKey</typeparam>
        /// <typeparam name="TValue">TValue</typeparam>
        /// <param name="strSql">strSql</param>
        /// <param name="columnName">需要作为Tkey主键的栏位</param>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <returns>DataSet</returns>
        Dictionary<TKey, TValue> Query<TKey, TValue>(string strSql, string columnName, bool userMasterConnection);
        /// <summary>
        /// 执行查询语句，返回DataSet
        /// </summary>
        /// <typeparam name="TKey">TKey</typeparam>
        /// <typeparam name="TValue">TValue</typeparam>
        /// <param name="strSql">strSql</param>
        /// <param name="columnName">需要作为Tkey主键的栏位</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns>DataSet</returns>
        Dictionary<TKey, TValue> Query<TKey, TValue>(string strSql, string columnName, string connectionString = "");
        /// <summary>
        /// 执行查询语句，返回DataTable
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        DataTable Query(string strSql, bool userMasterConnection, params DBParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句，返回DataTable
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        DataTable Query(string strSql, params DBParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句，返回DataTable
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        DataTable Query(string strSql, bool userMasterConnection, params IDataParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句，返回DataTable
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        DataTable Query(string strSql, params IDataParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句，返回DataTable
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        DataTable Query(string strSql, string connectionString = "", params DBParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句，返回DataTable
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        DataTable Query(string strSql, string connectionString = "", params IDataParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句，返回List[T]
        /// </summary>
        /// <param name="strSql">strSql</param>
        /// <typeparam name="T">entity</typeparam>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <returns>DataSet</returns>
        List<T> Query<T>(string strSql, bool userMasterConnection);
        /// <summary>
        /// 执行查询语句，返回List[T]
        /// </summary>
        /// <param name="strSql">strSql</param>
        /// <typeparam name="T">entity</typeparam>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns>DataSet</returns>
        List<T> Query<T>(string strSql, string connectionString = "");
        /// <summary>
        /// 执行查询语句,返回Json格式字符串List
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <returns></returns>
        string Query4Json(string strSql, bool userMasterConnection);
        /// <summary>
        /// 执行查询语句,返回Json格式字符串List
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns></returns>
        string Query4Json(string strSql, string connectionString = "");
        /// <summary>
        /// 执行查询语句
        /// </summary>
        /// <typeparam name="TKey">TKey</typeparam>
        /// <typeparam name="TValue">TValue</typeparam>
        /// <param name="strSql">strSql</param>
        /// <param name="columnName">需要作为Tkey主键的栏位</param>
        /// <param name="cmdParms"></param>
        /// <returns>DataSet</returns>
        Dictionary<TKey, TValue> Query<TKey, TValue>(string strSql, string columnName, params DBParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句
        /// </summary>
        /// <typeparam name="TKey">TKey</typeparam>
        /// <typeparam name="TValue">TValue</typeparam>
        /// <param name="strSql">str Sql</param>
        /// <param name="columnName">column Name</param>
        /// <param name="cmdParms">查询参数</param>
        /// <returns>DataSet</returns>
        Dictionary<TKey, TValue> Query<TKey, TValue>(string strSql, string columnName, params IDataParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句
        /// </summary>
        /// <typeparam name="TKey">TKey</typeparam>
        /// <typeparam name="TValue">TValue</typeparam>
        /// <param name="strSql">str Sql</param>
        /// <param name="columnName">需要作为Tkey主键的栏位</param>
        /// <param name="userMasterConnection">使用主库查询</param>
        /// <param name="cmdParms">查询参数</param>
        /// <returns>DataSet</returns>
        Dictionary<TKey, TValue> Query<TKey, TValue>(string strSql, string columnName, bool userMasterConnection, params DBParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句
        /// </summary>
        /// <typeparam name="TKey">TKey</typeparam>
        /// <typeparam name="TValue">TValue</typeparam>
        /// <param name="strSql">str Sql</param>
        /// <param name="columnName">需要作为Tkey主键的栏位</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="cmdParms">查询参数</param>
        /// <returns>DataSet</returns>
        Dictionary<TKey, TValue> Query<TKey, TValue>(string strSql, string columnName, string connectionString = "", params DBParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句
        /// </summary>
        /// <typeparam name="TKey">TKey</typeparam>
        /// <typeparam name="TValue">TValue</typeparam>
        /// <param name="strSql">str Sql</param>
        /// <param name="columnName">需要作为Tkey主键的栏位</param>
        /// <param name="userMasterConnection">使用主库查询</param>
        /// <param name="cmdParms">查询参数</param>
        /// <returns>DataSet</returns>
        Dictionary<TKey, TValue> Query<TKey, TValue>(string strSql, string columnName, bool userMasterConnection, params IDataParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句
        /// </summary>
        /// <typeparam name="TKey">TKey</typeparam>
        /// <typeparam name="TValue">TValue</typeparam>
        /// <param name="strSql">str Sql</param>
        /// <param name="columnName">需要作为Tkey主键的栏位</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="cmdParms">查询参数</param>
        /// <returns>DataSet</returns>
        Dictionary<TKey, TValue> Query<TKey, TValue>(string strSql, string columnName, string connectionString = "", params IDataParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句
        /// </summary>
        /// <param name="strSql">strSql</param>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <typeparam name="T">entity</typeparam>
        /// <param name="cmdParms">查询参数</param>
        /// <returns>DataSet</returns>
        List<T> Query<T>(string strSql, bool userMasterConnection, params DBParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句，返回List[T]
        /// </summary>
        /// <param name="strSql">strSql</param>
        /// <typeparam name="T">entity</typeparam>
        /// <param name="cmdParms">查询参数</param>
        /// <returns>DataSet</returns>
        List<T> Query<T>(string strSql, params DBParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句
        /// </summary>
        /// <param name="strSql">strSql</param>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <typeparam name="T">entity</typeparam>
        /// <param name="cmdParms">查询参数</param>
        /// <returns>DataSet</returns>
        List<T> Query<T>(string strSql, bool userMasterConnection, params IDataParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句，返回List[T]
        /// </summary>
        /// <param name="strSql">strSql</param>
        /// <typeparam name="T">entity</typeparam>
        /// <param name="cmdParms">查询参数</param>
        /// <returns>DataSet</returns>
        List<T> Query<T>(string strSql, params IDataParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句
        /// </summary>
        /// <param name="strSql">strSql</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <typeparam name="T">entity</typeparam>
        /// <param name="cmdParms">查询参数</param>
        /// <returns>DataSet</returns>
        List<T> Query<T>(string strSql, string connectionString = "", params DBParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句，返回List[T]
        /// </summary>
        /// <param name="strSql">strSql</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <typeparam name="T">entity</typeparam>
        /// <param name="cmdParms">查询参数</param>
        /// <returns>DataSet</returns>
        List<T> Query<T>(string strSql, string connectionString="", params IDataParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句
        /// </summary>
        /// <param name="strSql">strSql</param>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <param name="cmdParms">查询参数</param>
        /// <returns>DataSet</returns>
        string Query4Json(string strSql, bool userMasterConnection, params DBParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句，返回Json 格式数据list
        /// </summary>
        /// <param name="strSql">strSql</param>
        /// <param name="cmdParms">查询参数</param>
        /// <returns>DataSet</returns>
        string Query4Json(string strSql, params DBParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句
        /// </summary>
        /// <param name="strSql">strSql</param>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <param name="cmdParms">查询参数</param>
        /// <returns>DataSet</returns>
        string Query4Json(string strSql, bool userMasterConnection, params IDataParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句，返回Json 格式数据list
        /// </summary>
        /// <param name="strSql">strSql</param>
        /// <param name="cmdParms">查询参数</param>
        /// <returns></returns>
        string Query4Json(string strSql, params IDataParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句，返回Json 格式数据list
        /// </summary>
        /// <param name="strSql">strSql</param>
        /// <param name="cmdParms">查询参数</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns>DataSet</returns>
        string Query4Json(string strSql, string connectionString = "", params DBParameter[] cmdParms);
        /// <summary>
        /// 执行查询语句，返回Json 格式数据list
        /// </summary>
        /// <param name="strSql">strSql</param>
        /// <param name="cmdParms">查询参数</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns>DataSet</returns>
        string Query4Json(string strSql, string connectionString = "", params IDataParameter[] cmdParms);

        #region 执行分页查询

        #region 分页返回DataTable
        /// <summary>
        /// 分页查询
        /// Paging query
        /// </summary>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(total Count)</param>
        /// <param name="pageIndex">第几页(page Index)</param>
        /// <param name="pageSize">每页的数据行数(page Size)</param>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <returns>Data Table</returns>
        DataTable Query(string strSql, bool userMasterConnection, out int totalCount, int pageIndex = 1, int pageSize = 20);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(total Count)</param>
        /// <param name="pageIndex">第几页(page Index)</param>
        /// <param name="pageSize">每页的数据行数(page Size)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns>Data Table</returns>
        DataTable Query(string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, string connectionString="");
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(total Count)</param>
        /// <param name="pageIndex">第几页(page Index)</param>
        /// <param name="pageSize">每页的数据行数(page Size)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns>Data Table</returns>
        DataTable Query(string strSql, out int totalCount, string connectionString, int pageIndex = 1, int pageSize = 20);
        /// <summary>
        /// 分页查询
        /// Paging query
        /// </summary>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(total Count)</param>
        /// <param name="pageIndex">第几页(page Index)</param>
        /// <param name="pageSize">每页的数据行数(page Size)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <returns>Data Table</returns>
        DataTable Query(string strSql, bool userMasterConnection, out int totalCount, int pageIndex = 1, int pageSize = 20, params DBParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(total Count)</param>
        /// <param name="pageIndex">第几页(page Index)</param>
        /// <param name="pageSize">每页的数据行数(page Size)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>Data Table</returns>
        DataTable Query(string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, params DBParameter[] cmdParms);
        /// <summary>
        /// 分页查询
        /// Paging query
        /// </summary>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(total Count)</param>
        /// <param name="pageIndex">第几页(page Index)</param>
        /// <param name="pageSize">每页的数据行数(page Size)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <returns>Data Table</returns>
        DataTable Query(string strSql, bool userMasterConnection, out int totalCount, int pageIndex = 1, int pageSize = 20, params IDataParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(total Count)</param>
        /// <param name="pageIndex">第几页(page Index)</param>
        /// <param name="pageSize">每页的数据行数(page Size)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>Data Table</returns>
        DataTable Query(string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, params IDataParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(total Count)</param>
        /// <param name="pageIndex">第几页(page Index)</param>
        /// <param name="pageSize">每页的数据行数(page Size)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>Data Table</returns>
        DataTable Query(string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, string connectionString = "", params DBParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(total Count)</param>
        /// <param name="pageIndex">第几页(page Index)</param>
        /// <param name="pageSize">每页的数据行数(page Size)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>Data Table</returns>
        DataTable Query(string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, string connectionString = "", params IDataParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(total Count)</param>
        /// <param name="pageIndex">第几页(page Index)</param>
        /// <param name="pageSize">每页的数据行数(page Size)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>Data Table</returns>
        DataTable Query(string strSql, out int totalCount, string connectionString, int pageIndex = 1, int pageSize = 20, params DBParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(total Count)</param>
        /// <param name="pageIndex">第几页(page Index)</param>
        /// <param name="pageSize">每页的数据行数(page Size)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>Data Table</returns>
        DataTable Query(string strSql, out int totalCount, string connectionString, int pageIndex = 1, int pageSize = 20, params IDataParameter[] cmdParms);
        #endregion

        #region 分页返回List<T>
        /// <summary>
        /// 分页查询
        /// Paging query
        /// </summary>
        /// <typeparam name="T">泛型类型</typeparam>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <returns></returns>
        List<T> Query<T>(string strSql, bool userMasterConnection, out int totalCount, int pageIndex = 1, int pageSize = 20);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <typeparam name="T">泛型类型</typeparam>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <returns></returns>
        List<T> Query<T>(string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, string connectionString = "");
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <typeparam name="T">泛型类型</typeparam>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <returns></returns>
        List<T> Query<T>(string strSql, out int totalCount, string connectionString, int pageIndex = 1, int pageSize = 20);
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <typeparam name="T">泛型类型</typeparam>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        List<T> Query<T>(string strSql, bool userMasterConnection, out int totalCount, int pageIndex = 1, int pageSize = 20, params DBParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// </summary>
        /// <typeparam name="T">泛型类型</typeparam>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        List<T> Query<T>(string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, params DBParameter[] cmdParms);
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <typeparam name="T">泛型类型</typeparam>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        List<T> Query<T>(string strSql, bool userMasterConnection, out int totalCount, int pageIndex = 1, int pageSize = 20, params IDataParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <typeparam name="T">泛型类型</typeparam>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        List<T> Query<T>(string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, params IDataParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <typeparam name="T">泛型类型</typeparam>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        List<T> Query<T>(string strSql, out int totalCount, string connectionString, int pageIndex = 1, int pageSize = 20, params IDataParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <typeparam name="T">泛型类型</typeparam>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        List<T> Query<T>(string strSql, out int totalCount, string connectionString, int pageIndex = 1, int pageSize = 20, params DBParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <typeparam name="T">泛型类型</typeparam>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        List<T> Query<T>(string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, string connectionString = "", params IDataParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <typeparam name="T">泛型类型</typeparam>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        List<T> Query<T>(string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, string connectionString = "", params DBParameter[] cmdParms);
        #endregion

        #region 分页查询返回Json
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// </summary>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns>List</returns>
        string Query4Json(string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, string connectionString = "");
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// </summary>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns>List</returns>
        string Query4Json(string strSql, out int totalCount, string connectionString, int pageIndex = 1, int pageSize = 20);
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <returns>List</returns>
        string Query4Json(string strSql, bool userMasterConnection, out int totalCount, int pageIndex = 1, int pageSize = 20, params DBParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// </summary>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        string Query4Json(string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, params DBParameter[] cmdParms);
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <returns>List</returns>
        string Query4Json(string strSql, bool userMasterConnection, out int totalCount, int pageIndex = 1, int pageSize = 20, params IDataParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        string Query4Json(string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, params IDataParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// </summary>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        string Query4Json(string strSql, out int totalCount, string connectionString, int pageIndex = 1, int pageSize = 20, params DBParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        string Query4Json(string strSql, out int totalCount, string connectionString, int pageIndex = 1, int pageSize = 20, params IDataParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// </summary>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        string Query4Json(string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, string connectionString = "", params DBParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        string Query4Json(string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, string connectionString = "", params IDataParameter[] cmdParms);
        #endregion

        #region 带前缀分页返回DataTable
        /// <summary>
        /// 分页查询
        /// Paging query
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(total Count)</param>
        /// <param name="pageIndex">第几页(page Index)</param>
        /// <param name="pageSize">每页的数据行数(page Size)</param>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <returns>Data Table</returns>
        DataTable Query(string prefixSql, string strSql, bool userMasterConnection, out int totalCount, int pageIndex = 1, int pageSize = 20);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(total Count)</param>
        /// <param name="pageIndex">第几页(page Index)</param>
        /// <param name="pageSize">每页的数据行数(page Size)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns>Data Table</returns>
        DataTable Query(string prefixSql, string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, string connectionString = "");
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(total Count)</param>
        /// <param name="pageIndex">第几页(page Index)</param>
        /// <param name="pageSize">每页的数据行数(page Size)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns>Data Table</returns>
        DataTable Query(string prefixSql, string strSql, out int totalCount, string connectionString, int pageIndex = 1, int pageSize = 20);
        /// <summary>
        /// 分页查询
        /// Paging query
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <param name="totalCount">总数据行(total Count)</param>
        /// <param name="pageIndex">第几页(page Index)</param>
        /// <param name="pageSize">每页的数据行数(page Size)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>Data Table</returns>
        DataTable Query(string prefixSql, string strSql, bool userMasterConnection, out int totalCount, int pageIndex = 1, int pageSize = 20, params DBParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(total Count)</param>
        /// <param name="pageIndex">第几页(page Index)</param>
        /// <param name="pageSize">每页的数据行数(page Size)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>Data Table</returns>
        DataTable Query(string prefixSql, string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, params DBParameter[] cmdParms);
        /// <summary>
        /// 分页查询
        /// Paging query
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <param name="totalCount">总数据行(total Count)</param>
        /// <param name="pageIndex">第几页(page Index)</param>
        /// <param name="pageSize">每页的数据行数(page Size)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>Data Table</returns>
        DataTable Query(string prefixSql, string strSql, bool userMasterConnection, out int totalCount, int pageIndex = 1, int pageSize = 20, params IDataParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(total Count)</param>
        /// <param name="pageIndex">第几页(page Index)</param>
        /// <param name="pageSize">每页的数据行数(page Size)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>Data Table</returns>
        DataTable Query(string prefixSql, string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, params IDataParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(total Count)</param>
        /// <param name="pageIndex">第几页(page Index)</param>
        /// <param name="pageSize">每页的数据行数(page Size)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>Data Table</returns>
        DataTable Query(string prefixSql, string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, string connectionString = "", params DBParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(total Count)</param>
        /// <param name="pageIndex">第几页(page Index)</param>
        /// <param name="pageSize">每页的数据行数(page Size)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>Data Table</returns>
        DataTable Query(string prefixSql, string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, string connectionString = "", params IDataParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(total Count)</param>
        /// <param name="pageIndex">第几页(page Index)</param>
        /// <param name="pageSize">每页的数据行数(page Size)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>Data Table</returns>
        DataTable Query(string prefixSql, string strSql, out int totalCount, string connectionString, int pageIndex = 1, int pageSize = 20, params DBParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(total Count)</param>
        /// <param name="pageIndex">第几页(page Index)</param>
        /// <param name="pageSize">每页的数据行数(page Size)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>Data Table</returns>
        DataTable Query(string prefixSql, string strSql, out int totalCount, string connectionString, int pageIndex = 1, int pageSize = 20, params IDataParameter[] cmdParms);
        #endregion

        #region 带前缀分页返回List<T>
        /// <summary>
        /// 分页查询
        /// Paging query
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <typeparam name="T">泛型类型</typeparam>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <returns></returns>
        List<T> Query<T>(string prefixSql, string strSql, bool userMasterConnection, out int totalCount, int pageIndex = 1, int pageSize = 20);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <typeparam name="T">泛型类型</typeparam>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <returns></returns>
        List<T> Query<T>(string prefixSql, string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, string connectionString = "");
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <typeparam name="T">泛型类型</typeparam>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <returns></returns>
        List<T> Query<T>(string prefixSql, string strSql, out int totalCount, string connectionString, int pageIndex = 1, int pageSize = 20);
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <typeparam name="T">泛型类型</typeparam>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        List<T> Query<T>(string prefixSql, string strSql, bool userMasterConnection, out int totalCount, int pageIndex = 1, int pageSize = 20, params DBParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <typeparam name="T">泛型类型</typeparam>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        List<T> Query<T>(string prefixSql, string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, params DBParameter[] cmdParms);
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <typeparam name="T">泛型类型</typeparam>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        List<T> Query<T>(string prefixSql, string strSql, bool userMasterConnection, out int totalCount, int pageIndex = 1, int pageSize = 20, params IDataParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <typeparam name="T">泛型类型</typeparam>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        List<T> Query<T>(string prefixSql, string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, params IDataParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <typeparam name="T">泛型类型</typeparam>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        List<T> Query<T>(string prefixSql, string strSql, out int totalCount, string connectionString, int pageIndex = 1, int pageSize = 20, params IDataParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <typeparam name="T">泛型类型</typeparam>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        List<T> Query<T>(string prefixSql, string strSql, out int totalCount, string connectionString, int pageIndex = 1, int pageSize = 20, params DBParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <typeparam name="T">泛型类型</typeparam>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        List<T> Query<T>(string prefixSql, string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, string connectionString = "", params IDataParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <typeparam name="T">泛型类型</typeparam>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        List<T> Query<T>(string prefixSql, string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, string connectionString = "", params DBParameter[] cmdParms);
        #endregion

        #region 带前缀分页查询返回Json
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <returns>List</returns>
        string Query4Json(string prefixSql, string strSql, bool userMasterConnection, out int totalCount, int pageIndex = 1, int pageSize = 20);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns>List</returns>
        string Query4Json(string prefixSql, string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, string connectionString = "");
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns>List</returns>
        string Query4Json(string prefixSql, string strSql, out int totalCount, string connectionString, int pageIndex = 1, int pageSize = 20);
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <returns>List</returns>
        string Query4Json(string prefixSql, string strSql, bool userMasterConnection, out int totalCount, int pageIndex = 1, int pageSize = 20, params DBParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        string Query4Json(string prefixSql, string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, params DBParameter[] cmdParms);
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <param name="userMasterConnection">是否使用主库进行查询</param>
        /// <returns>List</returns>
        string Query4Json(string prefixSql, string strSql, bool userMasterConnection, out int totalCount, int pageIndex = 1, int pageSize = 20, params IDataParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        string Query4Json(string prefixSql, string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, params IDataParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        string Query4Json(string prefixSql, string strSql, out int totalCount, string connectionString, int pageIndex = 1, int pageSize = 20, params DBParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        string Query4Json(string prefixSql, string strSql, out int totalCount, string connectionString, int pageIndex = 1, int pageSize = 20, params IDataParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        string Query4Json(string prefixSql, string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, string connectionString = "", params DBParameter[] cmdParms);
        /// <summary>
        /// 分页查询(SqlServer的分页必须出现 order by 语句)
        /// Paging query
        /// </summary>
        /// <param name="prefixSql">前缀SQL</param>
        /// <param name="strSql">
        /// 需要执行分页的SQL
        /// [如果Sql中带排序字段,则排序字段必须出现再Select的字段中,并且程序会自动将Sql中的排序作为查询的排序]
        /// </param>        
        /// <param name="totalCount">总数据行(totalCount)</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="pageIndex">第几页(pageIndex)</param>
        /// <param name="pageSize">每页的数据行数(pageSize)</param>
        /// <param name="cmdParms">查询参数(cmdParms)</param>
        /// <returns>List</returns>
        string Query4Json(string prefixSql, string strSql, out int totalCount, int pageIndex = 1, int pageSize = 20, string connectionString = "", params IDataParameter[] cmdParms);
        #endregion

        #endregion

        #endregion

        #region 存储过程操作
        /*
        /// <summary>
        /// 执行存储过程 返回IDataReader ( 注意：调用该方法后，一定要对IDataReader进行Close )
        /// </summary>
        /// <param name="storedProcName">存储过程名</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns>OracleDataReader</returns>
        IDataReader RunProcedure(string storedProcName, string connectionString = "");

        /// <summary>
        /// 执行存储过程 返回IDataReader ( 注意：调用该方法后，一定要对IDataReader进行Close )
        /// </summary>
        /// <param name="storedProcName">存储过程名</param>
        /// <param name="parameters">存储过程参数</param>
        /// <returns>OracleDataReader</returns>
        IDataReader RunProcedure(string storedProcName, params DBParameter[] parameters);
        /// <summary>
        /// 执行存储过程 返回IDataReader ( 注意：调用该方法后，一定要对IDataReader进行Close )
        /// </summary>
        /// <param name="storedProcName">存储过程名</param>
        /// <param name="parameters">存储过程参数</param>
        /// <returns>OracleDataReader</returns>
        IDataReader RunProcedure(string storedProcName, params IDataParameter[] parameters);
        /// <summary>
        /// 执行存储过程 返回IDataReader ( 注意：调用该方法后，一定要对IDataReader进行Close )
        /// </summary>
        /// <param name="storedProcName">存储过程名</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="parameters">存储过程参数</param>
        /// <returns>OracleDataReader</returns>
        IDataReader RunProcedure(string storedProcName,string connectionString="", params DBParameter[] parameters);
        /// <summary>
        /// 执行存储过程 返回IDataReader ( 注意：调用该方法后，一定要对IDataReader进行Close )
        /// </summary>
        /// <param name="storedProcName">存储过程名</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="parameters">存储过程参数</param>
        /// <returns>OracleDataReader</returns>
        IDataReader RunProcedure(string storedProcName, string connectionString = "", params IDataParameter[] parameters);
        */
        /// <summary>
        /// 执行存储过程
        /// </summary>
        /// <param name="storedProcName">存储过程名</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="tableName">DataSet结果中的表名</param>
        /// <returns>DataSet</returns>
        DataSet RunProcedure(string storedProcName, string tableName, string connectionString = "");
        /// <summary>
        /// 执行存储过程
        /// </summary>
        /// <param name="storedProcName">存储过程名</param>
        /// <param name="parameters">存储过程参数</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="tableName">DataSet结果中的表名</param>
        /// <returns>DataSet</returns>
        DataSet RunProcedure(string storedProcName, string tableName, string connectionString = "", params DBParameter[] parameters);
        /// <summary>
        /// 执行存储过程
        /// </summary>
        /// <param name="storedProcName">存储过程名</param>
        /// <param name="parameters">存储过程参数</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="tableName">DataSet结果中的表名</param>
        /// <returns>DataSet</returns>
        DataSet RunProcedure(string storedProcName, string tableName, string connectionString = "", params IDataParameter[] parameters);
        /// <summary>
        /// 执行存储过程，返回影响的行数    
        /// </summary>
        /// <param name="storedProcName">存储过程名</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="rowsAffected">影响的行数</param>
        /// <returns></returns>
        int RunProcedure(string storedProcName, out int rowsAffected,string connectionString="");

        /// <summary>
        /// 执行存储过程，返回影响的行数    
        /// </summary>
        /// <param name="storedProcName">存储过程名</param>
        /// <param name="parameters">存储过程参数</param>
        /// <param name="rowsAffected">影响的行数</param>
        /// <returns></returns>
        int RunProcedure(string storedProcName, DBParameter[] parameters, out int rowsAffected);

        /// <summary>
        /// 执行存储过程，返回影响的行数    
        /// </summary>
        /// <param name="storedProcName">存储过程名</param>
        /// <param name="parameters">存储过程参数</param>
        /// <param name="rowsAffected">影响的行数</param>
        /// <returns></returns>
        int RunProcedure(string storedProcName, IDataParameter[] parameters, out int rowsAffected);

        /// <summary>
        /// 执行存储过程，返回影响的行数    
        /// </summary>
        /// <param name="storedProcName">存储过程名</param>
        /// <param name="parameters">存储过程参数</param>
        /// <param name="rowsAffected">影响的行数</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns></returns>
        int RunProcedure(string storedProcName, out int rowsAffected, string connectionString = "", params DBParameter[] parameters);
        /// <summary>
        /// 执行存储过程，返回影响的行数    
        /// </summary>
        /// <param name="storedProcName">存储过程名</param>
        /// <param name="parameters">存储过程参数</param>
        /// <param name="rowsAffected">影响的行数</param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns></returns>
        int RunProcedure(string storedProcName, out int rowsAffected, string connectionString = "", params IDataParameter[] parameters);
        #endregion

        #region OracleBulkCopy
        /// <summary>
        /// 批量导入数据
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="tableName"></param>
        /// <param name="disposeTable">是否销毁表,如果为false,则自动清空表数据</param>
        /// <returns></returns>
        bool BulkCopy(DataTable dt, string tableName, bool disposeTable = true);
        /// <summary>
        /// 批量导入数据
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="tableName"></param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="disposeTable">是否销毁表,如果为false,则自动清空表数据</param>
        /// <returns></returns>
        bool BulkCopy(DataTable dt, string tableName, string connectionString, bool disposeTable = true);
        /// <summary>
        /// 批量导入数据
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="tableName"></param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns></returns>
        bool BulkCopy(IDataReader reader, string tableName, string connectionString = "");
        /// <summary>
        /// 批量导入数据
        /// </summary>
        /// <param name="rows"></param>
        /// <param name="tableName"></param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns></returns>
        bool BulkCopy(DataRow[] rows, string tableName, string connectionString = "");
        /// <summary>
        /// 批量导入数据
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="rowState"></param>
        /// <param name="tableName"></param>
        /// <param name="disposeTable">是否销毁表</param>
        /// <returns></returns>
        bool BulkCopy(DataTable dt, DataRowState rowState, string tableName, bool disposeTable = true);
        /// <summary>
        /// 批量导入数据
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="rowState">需要写入到DB的Row状态</param>
        /// <param name="tableName"></param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <param name="disposeTable">是否销毁表</param>
        /// <returns></returns>
        bool BulkCopy(DataTable dt, DataRowState rowState, string tableName, string connectionString, bool disposeTable = true);

        /// <summary>
        /// 使用DataAdapter进行批量提交Insert,Update,Delete
        /// 如果使用Delete, DataTable中Row需要使用 Delete进行删除,不能使用Remove|RemoveAt进行移除,因为Delete只是注释数据行的状态
        /// 使用DataAdapter必须要求有主键
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns></returns>
        int DataAdapter(DataTable dt, string connectionString = "");
        /// <summary>
        /// 使用DataAdapter进行批量提交Insert,Update,Delete
        /// 如果使用Delete, DataTable中Row需要使用 Delete进行删除,不能使用Remove|RemoveAt进行移除,因为Delete只是注释数据行的状态
        /// 使用DataAdapter必须要求有主键
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="tableName"></param>
        /// <param name="unchangedDefaultState">
        /// 表结构中, Unchanged状态的Row 默认设置为哪种状态
        /// </param>
        /// <param name="connectionString">数据库链接字符串(为空则使用默认连接字符串)</param>
        /// <returns></returns>
        int DataAdapter(DataTable dt, string tableName, DataRowState unchangedDefaultState = DataRowState.Modified, string connectionString = "");

        #endregion
    }
}
